package 工厂方法模式.改进;

import 简单的工厂模式.工厂模式demo.计算器.Add;
import 简单的工厂模式.工厂模式demo.计算器.Div;
import 简单的工厂模式.工厂模式demo.计算器.Mul;
import 简单的工厂模式.工厂模式demo.计算器.Operation;
import 简单的工厂模式.工厂模式demo.计算器.Sub;

/**
 * @author zyl
 * @Description
 * @since 2024/1/3 13:28
 */

public class FactoryBasic implements IFactory {
    @Override
    public Operation creatOperation(String operator) {
        Operation operation = null;
        switch (operator){
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Sub();
                break;
            case "*":
                operation = new Mul();
                break;
            case "/":
                operation = new Div();
                break;
        }
        return operation;
    }
}
